function findFriends() {
	// alert('finding friends for ' + $('#friends_for').val());

	var request = opensocial.newDataRequest();
	var idspec = opensocial.newIdSpec( {
		"userId" :$('#friends_for').val(),
		"groupId" :"FRIENDS"
	});

	request.add(request.newFetchPeopleRequest(idspec), 'friends');

	request.send(parseFriends);
}

function parseFriends(data) {
	var friends = data.get('friends').getData();
	$('#friends').html("");
	if(friends.getTotalSize() > 0)
		friends.each(displayFriend);
	else
		$('#friends').html("<em>No friends found for user (or the user does not exist)</em>");
}

function displayFriend(friend){
	var name = friend.getField('name').getField('givenName')
	var family_name = friend.getField('name').getField('familyName')
	$('#friends').append('<li>' + family_name + ", " + name + '</li>')
}